Skip to content

dynamic namespace config #1187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
May 5, 2022
Merged

dynamic namespace config #1187

merged 24 commits into from
May 5, 2022

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Apr 29, 2022

No description provided.

@csviri csviri self-assigned this Apr 29, 2022
@csviri csviri changed the title dynamic namespace config WIP: dynamic namespace config Apr 29, 2022
@csviri csviri linked an issue May 1, 2022 that may be closed by this pull request
@csviri
Copy link
Collaborator Author

csviri commented May 2, 2022

@metacosm tomorrow will add tests, but this is the idea, does not look too scary for the moment.

@csviri csviri changed the title WIP: dynamic namespace config dynamic namespace config May 3, 2022
@csviri csviri marked this pull request as ready for review May 3, 2022 12:28
@csviri csviri requested a review from metacosm May 3, 2022 12:30
@metacosm metacosm self-assigned this May 3, 2022
this.namespaces = namespaces != null ? Set.of(namespaces) : Collections.emptySet();
return this;
return withNamespaces(
namespaces != null ? Set.of(namespaces) : ResourceConfiguration.DEFAULT_NAMESPACES);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This DEFAULT_NAMESPACES is a little confusing. Should we rename this to WATCH_ALL_NAMESPACES_ON_CLUSTER or such?

Since it is already defined as:
Set<String> DEFAULT_NAMESPACES = Collections.singleton(Constants.WATCH_ALL_NAMESPACES);

see:
https://github.com/java-operator-sdk/java-operator-sdk/blob/b9ee05e6e3c803be0b1e95633f465a632bd1dd52/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ResourceConfiguration.java#L13-L14

@metacosm

Copy link
Collaborator

@metacosm metacosm May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used DEFAULT_NAMESPACES because I thought it'd be a good idea to decouple the notion of what is used for the default value from the actual value so that it's clear at the usage site that we're using the default value because that's what should be used at that spot instead of an arbitrary value.

I do agree that it's a little confusing but I think it's better to keep this semantics to make it explicit that the default value is used at these spots. This way, the code using the value should also not change if the default value were to change.

Copy link
Collaborator Author

@csviri csviri May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that makes sense, I just I think found some places where it was not used, just the value directly, will rather then create PR for that if I find it again (can't remember where it was)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take a look

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's possible, unfortunately, ran into a couple of such occurrences myself as well and tried to fix them when I could.

@csviri
Copy link
Collaborator Author

csviri commented May 4, 2022

Regarding this part:
https://github.com/java-operator-sdk/java-operator-sdk/blob/c60e078d0e0ca6a6550c81201d6d26effd4d225f/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/Controller.java#L328-L334

I think it's fair to say that target namespaces for change should not contain these placeholders with special meaning just really a list of concrete namespace names.

@csviri csviri requested a review from metacosm May 4, 2022 08:14
@csviri csviri changed the base branch from next to main May 4, 2022 10:20
@csviri csviri force-pushed the dynamic-namespace-config branch from dd08cc2 to abc4da2 Compare May 4, 2022 10:21
@csviri
Copy link
Collaborator Author

csviri commented May 4, 2022

Wonder if we should do something like this with labels, but that is not that straightforward semantically. So would rather create a issue for that to discuss.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

49.6% 49.6% Coverage
0.0% 0.0% Duplication

@csviri csviri requested a review from metacosm May 4, 2022 13:52
Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@csviri csviri merged commit ef2c5f7 into main May 5, 2022
@csviri csviri deleted the dynamic-namespace-config branch May 5, 2022 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic namespaces
2 participants